package com.nineclock.message.listener;


import com.nineclock.message.pojo.NcMessage;
import com.nineclock.message.service.MessageService;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


@Component
@Slf4j
@RocketMQMessageListener(topic = "messagePushTopic",consumerGroup = "messagePushConsumer")
public class MsgListener implements RocketMQListener<NcMessage> {
    @Autowired
    MessageService messageService;


    @SneakyThrows
    @Override
    public void onMessage(NcMessage message) {
        log.info(message.getContent());
        messageService.pushSingleMessage(message);
    }
}
